{extend name="public/father" /}


{block name='main'}
<style>
    .layui-form-pane .layui-form-text{padding: 0 10px;}
    .layui-form-pane .layui-form-label{background: none !important;padding-left: 2px;border: 0;color:#000;}
    .layui-form-pane .layui-form-text input, .layui-form-pane .layui-form-text textarea{border-radius: 3px !important;}
</style>

<div class="layui-tab layui-tab-card">

    <ul class="layui-tab-title">

        {foreach $system_config as $k=>$v}

        {if $k == 'base'}

        <li {:input('param.group')=='base'||input('param.group') == null?' class="layui-this"':''}>
        <a href="{:url('admin/config/set')}?group={$k}">{$v}</a>
        </li>

        {else /}

        <li {:input('param.group')==  $k  ?' class="layui-this"':''}>
        <a href="{:url('admin/config/set')}?group={$k}">{$v}</a>
        </li>

        {/if}

        {/foreach}

    </ul>

    <div class="layui-tab-content" style="background: #FFFFFF;">

        <form class="layui-form layui-form-pane" action="">
            {foreach $data as $v}

            {if $v.type == 'input'}
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">{$v.title}</label>
                <div class="layui-input-block">
                    <input type="text" name="{$v.name}" value="{$v.value}" placeholder="请输入{$v.title}" autocomplete="off" class="layui-input">
                </div>
                {if !empty($v.tip)}
                <div class="layui-form-mid layui-word-aux">{:htmlspecialchars_decode($v.tips)}</div>
                {/if}
            </div>
            {/if}

            {if $v.type == 'textarea'}
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">{$v.title}</label>
                <div class="layui-input-block">
                    <textarea name="{$v.name}" placeholder="请输入{$v.title}" class="layui-textarea">{$v.value}</textarea>
                </div>
                {if !empty($v.tip)}
                <div class="layui-form-mid layui-word-aux">{:htmlspecialchars_decode($v.tips)}</div>
                {/if}
            </div>
            {/if}

            {if $v.type == 'switch'}
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">{$v.title}</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="{$v.name}" value="1" lay-skin="switch" lay-text="{$v['options'][1]?$v['options'][1]:'启用'}|{$v['options'][0]?$v['options'][0]:'禁用'}" {$v.value==1?' checked':''}>
                </div>
                {if !empty($v.tip)}
                <div class="layui-form-mid layui-word-aux">{:htmlspecialchars_decode($v.tips)}</div>
                {/if}
            </div>
            {/if}

            {if $v.type == 'radio'}
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">{$v.title}</label>
                <div class="layui-input-block">
                    {foreach $v.options as $kk => $vv}
                    <input type="radio" name="{$v.name}" value="{$kk}" title="{$vv}" {if condition="$kk eq $v.value"}checked{/if}>
                    {/foreach}
                </div>
                {if !empty($v.tip)}
                <div class="layui-form-mid layui-word-aux">{:htmlspecialchars_decode($v.tips)}</div>
                {/if}
            </div>
            {/if}

            {if $v.type == 'checkbox'}
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">{$v.title}</label>
                <div class="layui-input-block">
                    {foreach $v.options as $kk => $vv}
                    <input type="checkbox" name="{$v.name}[]" value="{$kk}" title="{$vv}" lay-skin="primary" {if condition="in_array($kk, $v['value'])"}checked{/if}>
                    {/foreach}
                </div>
                {if !empty($v.tip)}
                <div class="layui-form-mid layui-word-aux">{:htmlspecialchars_decode($v.tips)}</div>
                {/if}
            </div>
            {/if}

            {if $v.type == 'select'}
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">{$v.title}</label>
                <div class="layui-input-block">
                    <select name="{$v.name}" lay-verify="required">
                        {foreach $v.options as $kk => $vv}
                        <option value="{$kk}" {if condition="$kk eq $v.value"}selected{/if}>{$vv}</option>
                        {/foreach}
                    </select>
                </div>
                {if !empty($v.tip)}
                <div class="layui-form-mid layui-word-aux">{:htmlspecialchars_decode($v.tips)}</div>
                {/if}
            </div>
            {/if}

            {if $v.type == 'image'}
            <div class="layui-form-item layui-form-text upload">
                <label class="layui-form-label">{$v.title}</label>
                <div class="layui-input-block">
                    <input type="text" name="{$v.name}" value="{$v.value}" placeholder="请上传{$v.title}" autocomplete="off" class="layui-input upload-input">
                    <div style="position: absolute;right: 0px;top: 0px;">
                        <img class="upload-img" src="{$v.value}" style="max-height: 36px;" onclick="showImg(this.src);"><button type="button" class="layui-btn layui-btn-primary upload-button"><i class="layui-icon layui-icon-upload"></i>上传图片</button>
                    </div>
<!--                    <button type="button" class="layui-btn layui-btn-primary upload-button" style="position: absolute;right: 0px;top: 0px;"><i class="layui-icon layui-icon-upload"></i> 上传图片</button>-->
                    <!--                <img onclick="showImg(this.src);" class="upload-img" src="{$v.value}" style="height: 38px;">-->
                </div>
            </div>

            {/if}

            {if $v.type == 'file'}

            {/if}



            {if $v.type == 'tags'}

            {/if}

            {if $v.type == 'hidden'}

            {/if}

            {if $v.type == 'array'}
            <div class="layui-form-item">
                <label class="layui-form-label">{$v.title}</label>
                <div class="layui-input-inline">
                    <textarea class="layui-textarea" name="{$v.name}" autocomplete="off" placeholder="请填写{$v.title}">{$v.value}</textarea>
                </div>
                {if !empty($v.tip)}
                <div class="layui-form-mid layui-word-aux">{:htmlspecialchars_decode($v.tips)}</div>
                {/if}
            </div>
            {/if}

            {if $v.type == 'datetime'}

            {/if}

            {if $v.type == 'date'}

            {/if}

            {if $v.type == 'time'}

            {/if}

            {/foreach}
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="doit">立即提交</button>
                </div>
            </div>
        </form>

    </div>
</div>
{/block}

{block name="js"}
<script>
    layui.use(['table', 'layer', 'form'], function() {
        var table = layui.table,
            layer = layui.layer,
            form = layui.form,
            $ = layui.jquery;

        //监听提交
        form.on('submit(doit)', function(data){
            $.post("{:url()}?group={:input('param.group','base')}", data.field, function(res) {
                if(res.code == 1) {
                    success(res.msg);
                } else {
                    error(res.msg);
                }
            }, 'json');
            return false;
        });
    });
</script>
{/block}